﻿{template 'header'}
<script type="text/javascript">var errimg = '{DT_SKIN}image/nopic50.gif';</script>
<div class="m">
<div class="left_box">
	<div class="pos">
		You are here: <a href="{DT_PATH}">Home</a> 
		&raquo; <a href="{$MOD[linkurl]}">{$MOD[name]}</a>
		&raquo; Submit Order
	</div>
	<div class="b10">&nbsp;</div>
	<form method="post" action="{$MOD[linkurl]}buy.php" onsubmit="return check();">
	<input type="hidden" name="submit" value="1"/>
	<input type="hidden" name="itemid" value="{$itemid}"/>
	<div>
	<div class="f_r" style="padding:10px 50px 0 0;"><a href="{$MOD[linkurl]}">Return to re-pick</a></div>
	&nbsp;&nbsp;<img src="{DT_SKIN}image/buy_1.gif" width="160" height="30" alt=""/> 
	</div>
	<div style="margin:10px 40px 10px 40px;" class="c_b">
	<table cellpadding="6" cellspacing="1" width="100%" bgcolor="#E4E4E4">
	<tr align="center" bgcolor="#EEEEEE">
	<td width="60">Picture</td>
	<td>Commodity</td>
	<td width="60">Price</td>
	<td width="100">Quantity</td>
	<td width="90">Subtotal</td>
	</tr>
	<tr align="center" bgcolor="#FFFFFF">
	<td><a href="{$item[linkurl]}" target="_blank"><img src="{$item[thumb]}" width="50" alt="{$item[title]}"  onerror="this.src=errimg;"/></a></td>
	<td align="left"><a href="{$item[linkurl]}" target="_blank" class="px13 f_b">{$item[title]}</a>
	<div style="padding:8px 0 0 0;color:#666666;">Remark：<input type="text" name="note" value="" size="40" style="border:#CCCCCC 1px solid;" maxlength="100" title="Limited to 100 words or less"/></div>
	</td>
	<td><span class="f_price" id="price_{$itemid}">{$item[price]}</span></td>
	<td><img src="{DT_SKIN}image/arrow_l.gif" width="16" height="8" alt="Reduction" class="c_p" onclick="alter({$itemid}, '-')"/> <input type="text" name="number" value="1" size="3" style="border:#CCCCCC 1px solid;text-align:center;" id="number_{$itemid}" onblur="calculate();"/> <img src="{DT_SKIN}image/arrow_r.gif" width="16" height="8" alt="Addition" class="c_p" onclick="alter({$itemid}, '+')"/></td>
	<td><span class="f_price" id="total_{$itemid}">{$item[price]}</span></td>
	</tr>
	</table>
	<div class="b10">&nbsp;</div>
	<div style="border-top:#CCCCCC 1px solid;background:#F6F6F6;padding:20px 40px 20px 0;color:#666666;text-align:right;">
	Total：<span class="f_red f_b px16" id="total_amount">{$item[price]}</span> Yuan</div>
	</div>
	<div class="b10">&nbsp;</div>
	<div>&nbsp;&nbsp;<img src="{DT_SKIN}image/buy_2.gif" width="160" height="30" alt=""/></div>
	<div style="padding:20px;margin:10px 40px 20px 40px;background:#F4F4F4;" class="c_b px13">
	<table cellpadding="10" cellspacing="0" width="100%">
	{if $item[logistic]}
	<tr>
	<td width="100"><span class="f_red">&nbsp;</span> Useful Addresses：</td>
	<td class="px13" bgcolor="#F9F9F9">
	{if $address}
		{loop $address $k $v}
		<div>
		{if $k == 0}<span class="f_r"><a href="{$MODULE[2][linkurl]}address.php?action=add" target="_blank">[Add Address]</a>&nbsp;&nbsp;<a href="{$MODULE[2][linkurl]}address.php" target="_blank">[Manage Address]</a></span>{/if}
		<input type="radio" name="addr" id="addr_{$k}" value="{$v[address]}|{$v[postcode]}|{$v[truename]}|{$v[mobile]}|{$v[telephone]}" onclick="Adr(this.value);"{if $k == 0} checked{/if}/><label for="addr_{$k}"> {$v[postcode]} {$v[address]} ({$v[truename]}) {$v[mobile]}</label></div>
		<div class="b5"></div>
		{/loop}
	{else}
		<strong>No delivery address common</strong>&nbsp;&nbsp;<a href="{$MODULE[2][linkurl]}address.php?action=add" target="_blank">[Add Address]</a>&nbsp;&nbsp;<a href="{$MODULE[2][linkurl]}address.php" target="_blank">[Manage Address]</a>
	{/if}
	</td>
	</tr>
	<tr>
	<td><span class="f_red">*</span> Delivery Address：</td>
	<td><span id="addr_areaid">{ajax_area_select('add[areaid]', 'Please select', $user[areaid])} </span><input type="text" size="60" name="add[address]" id="address" value="{$user[address]}"/> <span id="daddress" class="f_red"></span></td>
	</tr>
	<tr>
	<td><span class="f_red">*</span> Zip code：</td>
	<td><input type="text" size="10" name="add[postcode]" id="postcode" value="{$user[postcode]}"/> <span id="dpostcode" class="f_red"></span></td>
	</tr>
	<tr>
	<td><span class="f_red">*</span> Real Name：</td>
	<td><input type="text" size="10" name="add[truename]" id="truename" value="{$user[truename]}"/> <span id="dtruename" class="f_red"></span></td>
	</tr>
	<tr>
	<td><span class="f_red">*</span> Cell Phone Number：</td>
	<td><input type="text" size="20" name="add[mobile]" id="mobile" value="{$user[mobile]}"/> <span id="dmobile" class="f_red"></span></td>
	</tr>
	<tr>
	<td><span class="f_red">&nbsp;</span> Phone number：</td>
	<td><input type="text" size="20" name="add[telephone]" id="telephone" value="{$user[telephone]}"/> <span id="dtelephone" class="f_red"></span></td>
	</tr>
	<tr>
	<td><span class="f_red">*</span> Expectations Logistics：</td>
	<td>
		<input type="text" size="10" name="add[receive]" id="receive"/>
		<select onchange="Dd('receive').value=this.value;">
		<option value="">Common types of logistics</option>
		{loop $send_types $v}
		<option value="{$v}">{$v}</option>
		{/loop}
		</select> <span id="dreceive" class="f_red"></span>
	</td>
	</tr>
	{else}
	<tr>
	<td><span class="f_red">*</span> Cell Phone Number：</td>
	<td><input type="text" size="30" name="add[mobile]" id="mobile" value="{$user[mobile]}"/> IMPORTANT: After successful purchase order ID number and password to be sent to your mobile phone, with text-to-business spending <span id="dmobile" class="f_red"></span></td>
	</tr>
	{/if}
	</table>
	</div>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr align="center">
	<td width="280"><input type="image" src="{DT_SKIN}image/btn_buynow.gif" title="Submit Order"/></td>
	<td width="280"><a href="{$MOD[linkurl]}" onclick="return confirm('Orders are not yet complete, you sure you want to leave this page?');"><img src="{DT_SKIN}image/btn_browse.gif" width="106" height="33" alt="Continue shopping"/></a></td>
	<td >&nbsp;</td>
	</tr>
	<tr align="center">
	<td class="f_gray">If you have determined to buy, please submit your order</td>
	<td class="f_gray">You can also return to {$ MOD [name]} First, continue to select items</td>
	<td height="50">&nbsp;</td>
	</tr>
	</table>
	</form>
</div>
</div>
<script type="text/javascript">
function check() {
	if(Dd('total_amount').innerHTML == '0.00') {
		alert('Orders amounted to 0.00, check the quantity');
		window.scroll(0, 0);
		return false;
	}
	var l;
	var f;
	{if $item[logistic]}
	f = 'address';
	l = Dd(f).value.length;
	if(l < 5) {
		Dmsg('Please fill out the street address', f);
		return false;
	}
	f = 'postcode';
	l = Dd(f).value.length;
	if(l < 6) {
		Dmsg('Please fill in ZIP', f);
		return false;
	}
	f = 'truename';
	l = Dd(f).value.length;
	if(l < 2) {
		Dmsg('Please fill out the real name', f);
		return false;
	}
	f = 'mobile';
	l = Dd(f).value.length;
	if(l < 11) {
		Dmsg('Please fill in mobile number', f);
		return false;
	}
	f = 'receive';
	l = Dd(f).value.length;
	if(l < 2) {
		Dmsg('Please fill out the expectations of logistics', f);
		return false;
	}
	{else}
	f = 'mobile';
	l = Dd(f).value.length;
	if(l < 11) {
		Dmsg('Please fill in mobile number', f);
		return false;
	}
	{/if}
	var m1 = {$_money};
	var m2 = parseFloat(Dd('total_amount').innerHTML);
	var m3 = m2 - m1;
	if(m2 > m1) {
		if(confirm('Account balance is insufficient, the need to recharge '+ m3 +' {$ DT [money_unit]}, whether immediate recharge?')) {
			window.open('{$MODULE[2][linkurl]}charge.php?action=pay&amount='+m3);
		}
		return false;
	}
	return confirm('You acknowledge commodity and shipping address is correct, submit this order?');
}
{if $item[logistic]}
function Adr(s) {
	var t = s.split('|');
	try {
		Dd('areaid_1').value = 0;
		Dh('addr_areaid');
		Dd('address').value = t[0];
		Dd('postcode').value = t[1];
		Dd('truename').value = t[2];
		Dd('mobile').value = t[3];
		Dd('telephone').value = t[4];		
	}
	catch (e) {}
}
{if $address}Adr(Dd('addr_0').value);{/if}
{/if}
function alter(i, t) {
	if(t == '+') {
		if(Dd('number_'+i).value >= 99) return;
		Dd('number_'+i).value =  parseInt(Dd('number_'+i).value) + 1;
	} else {
		if(Dd('number_'+i).value <= 0) return;
		Dd('number_'+i).value =  parseInt(Dd('number_'+i).value) - 1;
	}
	calculate();
}
function calculate() {
	var itemids = [{$itemid}];
	var _good = itemid = 0;
	for(var i = 0; i < itemids.length; i++) {
		itemid = itemids[i];
		var num, good;
		num = parseInt(Dd('number_'+itemid).value);
		if(isNaN(num) || num < 0) Dd('number_'+itemid).value = num = 1;
		good = parseFloat(Dd('price_'+itemid).innerHTML)*num;
		Dd('total_'+itemid).innerHTML = good.toFixed(2);
		_good += good;
	}
	Dd('total_amount').innerHTML = _good.toFixed(2);
}
calculate();
</script>
{template 'footer'}